<template>
  <div>
    <el-form
      :model="inputForm"
      size="small"
      ref="inputForm"
      v-loading="loading"
      :class="method === 'view' ? 'readonly' : ''"
      :disabled="method === 'view'"
      label-width="120px"
    >
      <el-row :gutter="15">
        <div class="line-bottom">活动配置</div>
        <el-col :span="24">
          <el-form-item
            label="活动名称:"
            prop="ticketName"
            :rules="[
              {
                required: true,
                message: '活动名称不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              v-model="inputForm.ticketName"
              placeholder="请填写活动名称"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="发券范围:"
            prop="ticketRange"
            :rules="[
              {
                required: true,
                message: '发券范围不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.ticketRange"
              placeholder="请选择发券范围"
            >
              <el-option
                v-for="item in ticketRangeList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" v-if="inputForm.ticketRange == 1 && isTicketType">
          <el-form-item
            label="发券商户:"
            prop="ticketType"
            :rules="[
              {
                required: true,
                message: '发券商户不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <select-page
              ref="searchRpiSelect"
              label="rpiName"
              value="rpiNo"
              :select.sync="inputForm.rpiNo"
              :url="website.searchLink.merchantUrl"
              placeholder-text="商户"
              filter-key="searchParam"
            ></select-page>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="活动类型:"
            prop="ticketType"
            :rules="[
              {
                required: true,
                message: '活动类型不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.ticketType"
              placeholder="请选择活动类型"
            >
              <el-option
                v-for="item in ticketTypeList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="充值类型:"
            prop="rechargeType"
            :rules="[
              {
                required: true,
                message: '充值类型不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.rechargeType"
              placeholder="请选择充值类型"
            >
              <el-option
                v-for="item in rechargeTypeList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <div style="padding: 0 40px; color: #999999">
            <p>商户不需要预先充值营销经费，即可创建和激活免充值代金券活动。</p>
            <p>
              活动生效后，用户到店使用微信支付，当订单符合优惠规则时，会直接扣减核销优惠商户的订单实收金额。
            </p>
            <p>
              免充值，营销资金“0”占用不需要预充值营销经费，即可创建代金券优惠活动。优惠金额从商户订单实收金额中扣减。
            </p>
            <p>
              免开发，免费使用微信支付提供基础防刷、对账、下载消耗记录等基础功能。不需要商户开发，也不收取手续费。
            </p>
            <p>
              可自定义各项活动规则可自定义活动标题、减价面额、减价门槛、可用商户、预算、用户领取次数限制，也可以配置指定会员可用、指定某些商品享受优惠等。
            </p>
          </div>
        </el-col>
        <div class="line-bottom">时效规则</div>
        <el-col :span="24">
          <div
            class="haruyuki-width-100"
            style="display: flex; align-items: center"
          >
            <el-form-item
              label="使用门槛:"
              prop="tradeAmount"
              :rules="[
                {
                  required: true,
                  message: '金额不能为空',
                  trigger: 'blur',
                },
              ]"
            >
              <div style="display: flex; align-items: center">
                <span style="width: 60px">交易满</span>
                <el-input
                  class="haruyuki-width-100"
                  placeholder="最低金额1元"
                  v-model="inputForm.tradeAmount"
                  onkeyup="value=value.replace(/[^\d^\.]+/g,'');value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
                ></el-input>
              </div>
            </el-form-item>
            <div style="margin: 0 10px; margin-bottom: 18px">元，减免</div>
            <el-form-item
              label=""
              label-width="0"
              prop="discountAmount"
              :rules="{
                required: true,
                message: '金额不能为空',
                trigger: 'blur',
              }"
            >
              <el-input
                v-model="inputForm.discountAmount"
                placeholder="请输入"
                onkeyup="value=value.replace(/[^\d^\.]+/g,'');value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
              ></el-input>
            </el-form-item>
            <div style="margin-bottom: 18px; margin-left: 8px">元</div>
          </div>
        </el-col>
        <el-col :span="24">
          <el-form-item
            prop="timeDate"
            label="有效期"
            :rules="[
              {
                required: true,
                message: '有效期不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-date-picker
              v-model="inputForm.timeDate"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              @change="timeDateChange"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <div
            class="haruyuki-width-100"
            style="display: flex; align-items: center"
          >
            <el-form-item
              label="券生效时间:"
              prop="validType"
              :rules="[
                {
                  required: true,
                  message: '券生效时间不能为空',
                  trigger: 'blur',
                },
              ]"
            >
              <div style="display: flex; align-items: center">
                <span style="width: 80px">领取券后</span>
                <el-select
                  class="width-100"
                  size="small"
                  v-model="inputForm.validType"
                  placeholder="请选择券生效时间"
                >
                  <el-option
                    v-for="item in validTypeList"
                    :key="item.dictKey"
                    :label="item.dictValue"
                    :value="Number(item.dictKey)"
                  >
                  </el-option>
                </el-select>
                <span style="margin-left: 8px">用户需在可用时间内使用</span>
              </div>
            </el-form-item>
          </div>
        </el-col>
        <el-col :span="24">
          <div
            class="haruyuki-width-100"
            style="display: flex; align-items: center"
          >
            <el-form-item
              label="使用规则:"
              prop="useType"
              :rules="[
                {
                  required: true,
                  message: '使用规则不能为空',
                  trigger: 'blur',
                },
              ]"
            >
              <el-radio-group
                style="display: flex; flex-direction: column"
                v-model="inputForm.useType"
              >
                <el-radio :label="1" style="display: flex; margin: 10px 0">
                  <span>有效期内，任意时段可用</span>
                </el-radio>
                <el-radio
                  :label="2"
                  style="display: flex; align-items: center; margin: 10px 0"
                >
                  <span style="margin-right: 8px">有效期内，用户领券后</span>
                  <el-input
                    class="width-100"
                    v-model="inputForm.dayInterval"
                    placeholder="请输入"
                    onkeyup="value=value.replace(/[^\d^\.]+/g,'');value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
                  ></el-input>
                  <span style="margin-left: 8px">天内可用</span>
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </div>
        </el-col>
        <el-col :span="24">
          <div style="padding: 0 40px; color: #999999">
            <p>
              用户在活动有效期开始前领取代金券，则从活动有效期第一天开始计算天数。
            </p>
            <p>用户在活动有效期内领取代金券，则从领取当天开始计算天数。</p>
            <p>无论用户何时领取代金券，代金券在活动有效期结束后均不可用。</p>
          </div>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="使用说明:"
            prop="ticketInstructions"
            :rules="[
              {
                required: true,
                message: '使用说明不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              type="textarea"
              v-model="inputForm.ticketInstructions"
              placeholder="请输入使用说明"
            ></el-input>
          </el-form-item>
        </el-col>
        <div class="line-bottom">发放配置</div>
        <el-col :span="24">
          <el-form-item
            label="发放总数:"
            prop="totalCount"
            :rules="[
              {
                required: true,
                message: '发放总数不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <div style="display: flex; align-items: center">
              <el-input
                class="haruyuki-width-100"
                placeholder="请输入"
                v-model="inputForm.totalCount"
                onkeyup="value=value.replace(/[^\d^\.]+/g,'');value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
              ></el-input>
              <span style="margin: 0 8px; width: 220px">个，每人限领</span>
              <el-input
                class="haruyuki-width-100"
                placeholder="请输入"
                v-model="inputForm.personCount"
                onkeyup="value=value.replace(/[^\d^\.]+/g,'');value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
              ></el-input>
              <span style="margin-left: 8px">个</span>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="发放限制:"
            prop="giveLimitType"
            :rules="[
              {
                required: true,
                message: '发放限制不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.giveLimitType"
              placeholder="请选择发放限制"
            >
              <el-option
                v-for="item in giveLimitTypeList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" v-if="inputForm.giveLimitType == 2">
          <el-form-item
            label="单日发放限制:"
            prop="giveLimitCount"
            :rules="[
              {
                required: true,
                message: '单日发放限制',
                trigger: 'blur',
              },
            ]"
          >
            <div style="display: flex; align-items: center">
              <el-input
                class="haruyuki-width-100"
                placeholder="请输入"
                v-model="inputForm.giveLimitCount"
                onkeyup="value=value.replace(/[^\d^\.]+/g,'');value=value.toString().match(/^\d+(?:\.\d{0,2})?/)"
              ></el-input>
              <span style="margin-left: 8px">个</span>
            </div>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
          <el-form-item
            label="可用商户:"
            prop="ticketType"
          >
            <select-page
              ref="searchRpisSelect"
              label="rpiName"
              value="rpiNo"
              :select.sync="inputForm.rpiNos"
              :url="website.searchLink.merchantUrl"
              placeholder-text="商户"
              filter-key="searchParam"
            ></select-page>
          </el-form-item>
        </el-col> -->
        <el-col :span="24" v-if="method === 'edit'">
          <el-form-item label="可用商户:" :rules="[]">
            <el-button type="primary" @click="handleService"
              >点击查看或设置</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="发放对象:"
            prop="givePersonType"
            :rules="[
              {
                required: true,
                message: '发放对象不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.givePersonType"
              placeholder="请选择发放对象"
            >
              <el-option
                v-for="item in givePersonTypeList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="发放方式:"
            prop="giveType"
            :rules="[
              {
                required: true,
                message: '发放方式不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-checkbox-group
              v-model="inputForm.giveType"
              @change="giveTypeChange"
            >
              <el-checkbox
                v-for="item in giveTypeList"
                :label="item.dictKey"
                :key="item.dictKey"
                :disabled="item.disabled"
                :value="item.dictKey"
                @change="giveTypeCheckChange($event, item)"
                >{{ item.dictValue }}</el-checkbox
              >
            </el-checkbox-group>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="使用限制:"
            prop="useLimitType"
            :rules="[
              {
                required: true,
                message: '使用限制不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.useLimitType"
              placeholder="请选择使用限制"
            >
              <el-option
                v-for="item in useLimitTypeList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item
            label="发券状态:"
            prop="ticketStatus"
            :rules="[
              {
                required: true,
                message: '发券状态不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-select
              class="width-100"
              size="small"
              v-model="inputForm.ticketStatus"
              placeholder="请选择发券状态"
            >
              <el-option
                v-for="item in ticketStatusList"
                :key="item.dictKey"
                :label="item.dictValue"
                :value="Number(item.dictKey)"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-image-viewer
        style="z-index: 99999"
        v-if="imgShow"
        :on-close="
          () => {
            imgShow = false;
          }
        "
        :url-list="imgUrlList"
      ></el-image-viewer>
      <!-- <avue-crud
        :option="option"
        :search.sync="search"
        :table-loading="loading"
        :data="inputForm.productList"
        :page.sync="page"
        :permission="permissionList"
        :before-open="beforeOpen"
        v-model="form"
        ref="crud"
        @row-update="rowUpdate"
        @row-save="rowSave"
        @row-del="rowDel"
        @search-change="searchChange"
        @search-reset="searchReset"
        @selection-change="selectionChange"
        @current-change="currentChange"
        @size-change="sizeChange"
        @refresh-change="refreshChange"
        @sort-change="sortChange"
        @on-load="onLoad"
      >
        <template slot="menuLeft">
        </template>
        <template slot="menuRight">
          <span style="margin-right: 5px" v-if="page.allPrice">
            <span style="color: #999">套餐总金额：</span>
            <span class="redFont">{{ page.allPrice }}元</span>
          </span>
        </template>
      </avue-crud> -->
    </el-form>
    <el-dialog
      class="avue-dialog"
      title="商户配置"
      top="2%"
      :width="
        screenWidth > 1920
          ? '65%'
          : screenWidth <= 1920 && screenWidth > 1500
          ? '65%'
          : '80%'
      "
      append-to-body
      :close-on-click-modal="false"
      :visible.sync="serviceDialog"
      v-if="serviceDialog"
      :before-close="handleCloseService"
    >
      <merchantTables
        ref="merchantTable"
        :id="inputForm.id"
        :rpiNo="inputForm.rpiNo"
      ></merchantTables>
    </el-dialog>
  </div>
</template>

<script>
import { getDictionary } from "@/api/system/dict";
// import { getList } from "@/api/rb-oem/activity/activity";
import { uploadPublic } from "@/api/system/oss";
import merchantTables from "./merchant-tables";
export default {
  props: {
    inputForm: {
      type: Object,
      default: () => {
        return {
          id: "",
          rpiNo: "",
          ticketCode: "",
          ticketName: "",
          ticketRange: 1,
          ticketRangeName: "",
          ticketType: null,
          ticketTypeName: "",
          rechargeType: null,
          rechargeTypeName: "",
          tradeAmount: "",
          discountAmount: "",
          startDate: "",
          endDate: "",
          validType: null,
          validTypeName: "",
          totalCount: null,
          personCount: null,
          receiveCount: null,
          useCount: null,
          giveLimitType: null,
          giveLimitTypeName: "",
          giveLimitCount: null,
          givePersonType: null,
          givePersonTypeName: "",
          useLimitType: null,
          useLimitTypeName: "",
          giveType: [],
          giveTypeName: "",
          ticketStatus: 1,
          ticketStatusName: "",
          ticketInstructions: "",
          useType: null,
          useRuleName: "",
          dayInterval: null,
          timeDate: [],
          rpiNos: "",
          rpiNoList: [],
          weekForm: {
            weekDay: "",
            datetimeForms: [],
          },
          dayForm: {
            dateDayForms: [],
            datetimeForms: [],
          },
          useStandard: "",
        };
      },
    },
    method: {
      type: String,
      default: "",
    },
  },
  components: {
    merchantTables,
  },
  data() {
    return {
      screenWidth: document.documentElement.clientWidth,
      imgShow: false,
      imgUrlList: [],
      logoFileList: [],
      loading: false,
      ticketTypeList: [],
      ticketRangeList: [],
      rechargeTypeList: [],
      givePersonTypeList: [],
      giveLimitTypeList: [],
      useLimitTypeList: [],
      ticketStatusList: [],
      validTypeList: [],
      giveTypeList: [],
      merchantActiveCodeList: [],
      data: [],
      search: {},
      form: {},
      query: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        allPrice: 0,
      },
      props: {
        label: "title",
        value: "key",
      },
      option: {
        //height: "auto",
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        viewBtn: false,
        selection: true,
        searchMenuSpan: 6,
        search: false,
        // columnBtn: false,
        addBtn: true,
        editBtn: true,
        column: [
          {
            label: "主键",
            prop: "id",
            type: "input",
            sortable: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            hide: true,
          },
          {
            label: "商品名称",
            prop: "productName",
            slot: true,
            overHidden: true,
            rules: [
              {
                required: true,
                message: "请输入商品名称",
                trigger: "blur",
              },
            ],
          },
          {
            label: "商品型号",
            prop: "productType",
            overHidden: true,
            rules: [
              {
                required: true,
                message: "请输入商品型号",
                trigger: "blur",
              },
            ],
          },
          {
            label: "是否可退",
            prop: "ifRefund",
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=pledge_if_refund",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "string",
            showColumn: false,
            rules: [
              {
                required: true,
                message: "请选择是否可退",
                trigger: "blur",
              },
            ],
            control: (val, form) => {
              return new Promise((resolve) => {
                // console.log(form, 'form');
                if (val === "0") {
                  resolve({
                    ifRefundAmt: {
                      value: "",
                      disabled: false,
                    },
                  });
                } else if (val === "1") {
                  resolve({
                    ifRefundAmt: {
                      value: "0",
                      disabled: true,
                    },
                  });
                }
              });
            },
          },
          {
            label: "是否可返",
            prop: "ifReturn",
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=pledge_if_return",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "string",
            showColumn: false,
            rules: [
              {
                required: true,
                message: "请选择是否可返",
                trigger: "blur",
              },
            ],
          },
          {
            label: "押金价格",
            prop: "price",
            overHidden: true,
            hide: true,
            rules: [
              {
                required: true,
                message: "请输入押金价格",
                trigger: "blur",
              },
            ],
          },
          {
            label: "退还金额",
            prop: "ifRefundAmt",
            overHidden: true,
            rules: [
              {
                required: true,
                message: "请输入退还金额",
                trigger: "blur",
              },
            ],
          },
          {
            label: "返现金额",
            prop: "ifReturnAmt",
            overHidden: true,
            rules: [
              {
                required: true,
                message: "请输入返现金额",
                trigger: "blur",
              },
            ],
          },
          {
            label: "商品大图",
            prop: "logo",
            type: "upload",
            listType: "picture-img",
            action: "/api/blade-resource/oss/endpoint/put-file-public",
            loadText: "图片上传中，请稍等",
            limit: 1,
            fileSize: 10240,
            span: 24,
            propsHttp: {
              res: "data",
              url: "link",
            },
            tip: "只能上传jpg/png文件，且不且不超过10Mb",
            showColumn: false,
            rules: [
              {
                required: true,
                message: "请上传商品大图",
                trigger: "blur",
              },
            ],
          },
          {
            label: "允许复购",
            prop: "isRepurchase",
            type: "select",
            dicUrl:
              "/api/blade-system/dict/dictionary?code=pledge_is_repurchase",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "string",
            showColumn: false,
            rules: [
              {
                required: true,
                message: "请选择是否允许复购",
                trigger: "blur",
              },
            ],
          },
        ],
      },
      ueditorOptions: {
        //普通上传地址
        action: "/api/blade-resource/oss/endpoint/put-file",
        customConfig: {}, //wangEditor编辑的配置
        props: {
          // home: '',
          res: "data",
          url: "link",
        },
      },
      serviceDialog: false,
      isTicketType: true,
    };
  },
  computed: {
    giveType() {
      let ids = this.inputForm.giveType;
      return ids.join(",");
    },
  },
  watch: {
    method: {
      handler(val) {
        if (val === "view") {
          this.option.editBtn = false;
          this.option.delBtn = false;
        } else {
          this.option.editBtn = true;
          this.option.delBtn = true;
        }
      },
      immediate: true,
      // deep: true
    },
    inputForm: {
      handler(val) {
        if (val) {
          this.doGetDicts();
        }
      },
      immediate: true,
      // deep: true
    },
  },
  created() {
    // this.doGetDicts();
  },
  methods: {
    /* 字典 */
    doGetDicts() {
      getDictionary({ code: "ticket_type" }).then((res) => {
        this.ticketTypeList = res.data.data;
      });
      getDictionary({ code: "ticket_range" }).then((res) => {
        this.ticketRangeList = res.data.data;
      });
      getDictionary({ code: "recharge_type" }).then((res) => {
        this.rechargeTypeList = res.data.data;
      });
      getDictionary({ code: "give_person_type" }).then((res) => {
        this.givePersonTypeList = res.data.data;
      });
      getDictionary({ code: "give_limit_type" }).then((res) => {
        this.giveLimitTypeList = res.data.data;
      });
      getDictionary({ code: "use_limit_type" }).then((res) => {
        this.useLimitTypeList = res.data.data;
      });
      getDictionary({ code: "ticket_status" }).then((res) => {
        this.ticketStatusList = res.data.data;
      });
      getDictionary({ code: "valid_type" }).then((res) => {
        this.validTypeList = res.data.data;
      });
      getDictionary({ code: "give_type" }).then((res) => {
        let giveTypeData = res.data.data;
        for (let i = 0; i < giveTypeData.length; i++) {
          this.$set(giveTypeData[i], "disabled", false);
        }
        this.$nextTick(() => {
          this.giveTypeList = giveTypeData;
          if (this.inputForm.giveType.length > 0) {
            if (this.inputForm.giveType.includes("1")) {
              this.giveTypeList[3].disabled = true;
            }
            if (this.inputForm.giveType.includes("4")) {
              this.giveTypeList[0].disabled = true;
            }
          }
        });
      });

      //   this.$nextTick(() => {
      //     if (this.inputForm.startDate && this.inputForm.endDate) {
      //       this.$set(this.inputForm, "timeDate", [
      //         this.inputForm.startDate,
      //         this.inputForm.endDate,
      //       ]);
      //     }
      //     this.$forceUpdate();
      //   });
    },
    handleService() {
      this.serviceDialog = true;
      this.$nextTick(() => {
        // this.$refs['merchantTable'].refreshList();
      });
    },
    handleCloseService(done) {
      this.$refs["merchantTable"].id = "";
      this.serviceDialog = false;
      // this.addForm.serviceList = this.$refs.serviceWhite.allData
      done();
    },
    timeDateChange(e) {
      this.inputForm.startDate = e[0];
      this.inputForm.endDate = e[1];
    },
    giveTypeChange(e) {
      // console.log(e, 'eeeeeeeeee');
      // for (const item of e) {
      //   if (item === '1') {

      //   }
      // }
      this.inputForm.giveType = e;
    },
    giveTypeCheckChange(e, row) {
      if (row.dictKey === "1") {
        this.giveTypeList[3].disabled = e;
      }
      if (row.dictKey === "4") {
        this.giveTypeList[0].disabled = e;
      }
    },
    /* 预览图片 */
    imgPreview(file) {
      this.imgUrlList[0] = file.url;
      this.imgShow = true;
    },
    beforeUpload(file) {},
    /* 文件超出个数限制时的钩子 */
    handHeldExceed() {
      this.$message.error("只能上传一张图片哦~");
    },
    /* 上传 */
    httplogoRequest(option) {
      uploadPublic(option.file, option.file.name).then((res) => {
        this.inputForm.logo = res.data.data.link;
        this.$refs.inputForm.validateField("logo");
      });
    },
    /* 删除 */
    logoRemove(file, fileList) {
      this.logoFileList = fileList;
      this.inputForm.logo = "";
    },
    beforelogoRemove() {
      return this.$confirm(`确定移除非法人身份证正面照片？`);
    },
    /**
     * @func 选中单元格
     * @desc 选中单元格数据
     * @param {list} list --- 选中单元格数据-数组
     * */
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    /**
     * @func 分页页码
     * @desc 分页页码改变时会触发
     * */
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      // this.refreshChange();
    },
    /**
     * @func 当前页个数
     * @desc pageSize改变时会触发
     * */
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      // this.refreshChange();
    },
    /**
     * @func 刷新
     * @desc 点击刷新按钮触发该事件
     * */
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    rowSave(row, done, loading) {
      this.inputForm.productList.push(row);
      setTimeout(() => {
        done();
        this.onLoad(this.page);
      }, 300);
    },
    rowUpdate(row, index, done, loading) {
      this.$nextTick(() => {
        this.inputForm.productList[index] = Object.assign(
          this.inputForm.productList[index],
          {
            ...row,
          }
        );
      });
      setTimeout(() => {
        done();
      }, 300);
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return this.inputForm.productList.splice(row.$index, 1);
        })
        .then(() => {
          this.onLoad(this.page);
        });
    },
    onLoad() {
      this.loading = true;
      let total = 0;
      //   for (const item of this.inputForm.productList) {
      //     total += Number(item.price);
      //   }
      //   this.$nextTick(() => {
      //     this.page.allPrice = Number(total.toFixed(2));
      //   });
      //   this.$forceUpdate();
      setTimeout(() => {
        this.loading = false;
      }, 300);
      //   if (this.awaitData.length > 0) {
      //     //awaitData为全部数据，data是目前表格绑定的数据
      //     this.data = this.awaitData.slice(
      //       (this.page.currentPage - 1) * this.page.pageSize,
      //       this.page.currentPage * this.page.pageSize
      //     );
      //     this.page.total = this.awaitData.length;
      //   }
      //   this.loading = false;
    },
  },
};
</script>

<style>
.redFont {
  color: red;
}
</style>